/*
 * Projekt: GMU 2013 - Canny hranovy detektor OpenCL/CUDA
 * Autori: Pavel Nevrala - xnevra00 (xnevra00@stud.fit.vutbr.cz)
 *         Martin Jurak - xjurak02 (xjurak02@stud.fit.vutbr.cz)
 */

#include "GaussianMask.h"

GaussianMask::GaussianMask(void): cv_gaussianMask(NULL), cl_gaussianMask(NULL)
{
}

GaussianMask::~GaussianMask(void)
{
	if(cv_gaussianMask){		
		delete cv_gaussianMask;
	}

	if(cl_gaussianMask)
		delete[] cl_gaussianMask;
}

/*
 * Vytvori linearni Guassovu masku.
 * Pro OpenCV typu Mat, pro OpenCL pole prvku typu cl_float 
 * @size - velikost masky
 * @sigma - odchylka pro Gaussovu masku
 */
void GaussianMask::createGaussianMask(int size, double sigma){

	cv_gaussianMask = new Mat();
	*cv_gaussianMask = getGaussianKernel(size,sigma,CV_32F);	

	cl_gaussianMask = new cl_float[size];
	if(cl_gaussianMask == NULL)
	{
		throw "Nepodarilo se vytvorit buffer pro Gaussovu masku!";
	}

	memcpy(cl_gaussianMask, cv_gaussianMask->data, cv_gaussianMask->rows* sizeof(cl_float));
}
